<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>新用户注册</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<jsp:include page="/WEB-INF/public/jquery-header.jsp"></jsp:include>
	<jsp:include page="/WEB-INF/public/bootstarp-header.jsp"></jsp:include>
  </head>
  <script type="text/javascript">
  	function reg(){
  		$.post(
  			"${pageContext.request.contextPath }/user/reg",
  			$("#loginform").serialize(),
  			function(data){
  				alert(data.stat+""+data.msg);
  				if(data.stat != 0 && data.stat != 6){
  					chageCode();
  				}
  			}
  		);
  		return false;
  	}
  	function chageCode() {var img = document.getElementById("codeImg");img.src = "${pageContext.request.contextPath }/user/reg_code?"+new Date();}
  </script>
  <style>
  #loginform{
	margin-top: 100px;
  	border: 1px white solid;
  	height: 450px;
  	background: white;
	border-radius: 10px;
  }
  .form-control{
  height: 50px}
  </style>
  <body>
  <jsp:include page="/WEB-INF/public/head.jsp"></jsp:include>
  <div class="jumbotron" >
  <div class="row">
  	<div class="col-md-10 col-md-offset-1">
  	<form id="loginform" action="#" method="post" class="form-horizontal">
		<div class="form-group" style="margin-top: 10px;">
			<label for="username" class="col-sm-2 control-label">用户名：</label>
			<div class="col-sm-3">
				<input type="text" class="form-control" id="username" name="username" placeholder="Username">
			</div>
		</div>
		<div class="form-group">
			<label for="password" class="col-sm-2 control-label">密码：</label>
			<div class="col-sm-3">
				<input type="password" class="form-control" id="password" name="password" placeholder="Password">
			</div>
		</div>
		<div class="form-group">
			<label for="password2" class="col-sm-2 control-label">重复密码：</label>
			<div class="col-sm-3">
				<input type="password" class="form-control" id="password2" name="password2" placeholder="Password">
			</div>
		</div>
		<div class="form-group">
			<label for="email" class="col-sm-2 control-label">邮箱：</label>
			<div class="col-sm-3">
				<input type="text" class="form-control" id="email" name="email" placeholder="Email">
			</div>
		</div>
		<div class="form-group">
			<div class="col-md-3 col-md-offset-2">
				<img id="codeImg" alt="验证码" src="${pageContext.request.contextPath }/user/reg_code" onclick="chageCode()"/>
			</div>
		</div>
		<div class="form-group">
			<label for="code" class="col-sm-2 control-label">验证码：</label>
			<div class="col-sm-3">
				<input type="text" class="form-control" id="code" name="code" placeholder="Verification code">
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-offset-2 col-sm-10">
		      <button type="button" class="btn btn-default" onclick="reg()">现在注册</button>
		    </div>
		</div>
  	</form>
  	</div>
  	
  	</div>
  </div>
  </body>
</html>
